package com.boding.power.utils;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Dates {
	public static String dateConverter(Date date){	
		return new SimpleDateFormat("yyyy-MM-dd HH-mm-ss").format(date);
	}
	public static long difference(String date1,String date2) throws Exception{
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		Date d1 = df.parse(date1);
	    Date d2 = df.parse(date2);
	    long diff = d1.getTime() - d2.getTime();
		long days = diff / (1000 * 60);
		return days;
	}
	public static String lastDate(Date date1) throws Exception{
		Date date3 = new Date(date1.getTime() + 30L * 24L * 60L * 60L * 1000L);
		return new SimpleDateFormat("yyyy-MM-dd").format(date3);
	}
}
